#include<stdio.h>

void reserve(int arr[0],int x,int y)
{
	int i = 0,j = 0;
	for(i = x-y; i < x; i++)
	{
		printf("%d ",arr[i]);
	}
	for(j = 0;j < x-y;j++ )
	{
		printf("%d ",arr[j]);
	}	
	
}

int main()
{
	int n = 0;
	int m = 0;
	scanf("%d",&n); 
	int arr[1000] = {0};
	int i = 0;
	for(i = 0; i < n;i++)
	{
		scanf("%d",&arr[i]);
	}
	scanf("%d",&m);
	reserve(arr,n,m);
	
	return 0;
}
